package tcc.wa.service.factory;

import tcc.wa.service.AlertService;
import tcc.wa.service.CurrentWeatherConditionService;
import tcc.wa.service.DailyWeatherForecastService;
import tcc.wa.service.HourlyWeatherForecastService;
import tcc.wa.service.LocationService;
import android.content.Context;

/**
 * A factory for creating Service objects.
 */
public abstract class ServiceFactory {

	private static LocationService locationService;

	private static CurrentWeatherConditionService currentWeatherConditionService;
	
	private static DailyWeatherForecastService dailyWeatherForecastService;
	
	private static HourlyWeatherForecastService hourlyWeatherForecastService;
	
	private static AlertService alertService;
	
	/**
	 * Gets the location service.
	 *
	 * @param context the application context
	 * @return the location service
	 */
	public static LocationService getLocationService(Context context) {
		if (locationService == null)
			locationService = new LocationService(context);
		return locationService;
	}
	
	/**
	 * Gets the current weather condition service.
	 *
	 * @param context the application context
	 * @return the current weather condition service
	 */
	public static CurrentWeatherConditionService getCurrentWeatherConditionService(Context context) {
		if (currentWeatherConditionService == null)
			currentWeatherConditionService = new CurrentWeatherConditionService(context);
		return currentWeatherConditionService;
	}
	
	/**
	 * Gets the daily weather forecast service.
	 *
	 * @param context the application context
	 * @return the daily weather forecast service
	 */
	public static DailyWeatherForecastService getDailyWeatherForecastService(Context context) {
		if (dailyWeatherForecastService == null)
			dailyWeatherForecastService = new DailyWeatherForecastService(context);
		return dailyWeatherForecastService;
	}
	
	/**
	 * Gets the hourly weather forecast service.
	 *
	 * @param context the application context
	 * @return the hourly weather forecast service
	 */
	public static HourlyWeatherForecastService getHourlyWeatherForecastService(Context context) {
		if (hourlyWeatherForecastService == null)
			hourlyWeatherForecastService = new HourlyWeatherForecastService(context);
		return hourlyWeatherForecastService;
	}
	
	/**
	 * Gets the alert service.
	 *
	 * @param context the application context
	 * @return the alert service
	 */
	public static AlertService getAlertService(Context context) {
		if (alertService == null)
			alertService = new AlertService(context);
		return alertService;
	}
}
